function $(id) {
    return document.getElementById(id);
}

function del(x) {//删除
    $('shopping').deleteRow(x.parentNode.parentNode.rowIndex);
}

function selectAll(x) {//全选
    var obj = document.getElementsByName('cartCheckBox');
    for (var i = 0; i < obj.length; i++) {
        if (x.checked == true) {
            obj[i].checked = true;  
        } else {
            obj[i].checked = false;
        }
    }
}

function delAdd(x) {//删除所选
    var obj = document.getElementsByName('cartCheckBox');
    var len = obj.length;
    for (var i = len - 1; i >= 0; i--) {
        var ierms = obj[i].checked;
        if (ierms) {
            var divierms = obj[i].parentNode.parentNode;
            divierms.parentNode.removeChild(divierms);
        }
    }

}

function add(x) {//加
    var num = x.parentElement.children[1].vlaue;
    x.parentElement.children[1].vlaue = ++num;
    var jia = x.parentElement.previousElementSibling.innerHTML;
    var tal = parseFloat(jia)*num;
    x.parentElement.nextElementSibling.innerHTML = tal;
}

function reduce(x) {//减
    var num = x.parentElement.children[1].vlaue;
    if(num = 0) {
        return false;
    }
    x.parentElement.children[1].vlaue = --num;
    var jia = x.parentElement.previousElementSibling.innerHTML;
    var tal = parseFloat(jia)*num;
    x.parentElement.nextElementSibling.innerHTML = tal;
}